{extend name="admin@public:layout" /}
{block name="content"}
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <div class="subject">
        <h3>数据库</h3>
        <h5>数据库恢复与备份</h5>
      </div>
      <ul class="tab-base nc-row">
            {include file="admin@public/nav" /}
      </ul>
  </div>
  </div>
  <!-- 操作说明 -->
  <div class="explanation" id="explanation">
    <div class="title" id="checkZoom"><i class="icon iconfont icon-dengpao"></i>
      <h4 class="itip" alt="提示相关设置操作时应注意的要点">操作提示</h4>
      <span id="explanationZoom" class="itip" alt="收起提示"></span> </div>
    <ul>
      <li>点击导入选项进行数据库恢复</li>
    </ul>
  </div>
  <!-- 表格 -->
  <div class="table_list">
    <div class="mDiv"><div class="ftitle"><h3>数据库备份列表</h3><h5></h5></div></div>
    <div class="hDiv">
        <table width="100%">
        <thead>
          <tr>
              <td width="150" align="center">操作</td>
              <td width="150" align="center">备份名</td>
              <td width="150" align="center">备份时间</td>
              <td width="150" align="center">备份大小</td>
              <td width="100" align="center">卷数</td>
              <td width="100" align="center">压缩</td>
              <td width="100" align="center">状态</td>
          </tr>
        </thead>
        </table>
    </div>

    <div class="bDiv">
      <table width="100%">
      <tbody>
        {volist name="_list" id="data"}
        <tr class="hover">
            <td width="150" align="center" class="handle">
            <span class="btn"><em><i class="icon iconfont icon-shezhi"></i>设置<i class="arrow"></i></em>
              <ul><li><a href="javascript:if(confirm('您确定要删除吗?')){location.href='{:url('del?time='.$data['time'])}'};">删除</a></li>
                  <li><a class="confirm-on-click" href="{:url('import?time='.$data['time'])}">导入</a></li>
                  <li><a href="{:url('downFile',array('type'=>'gz','file'=>date('Ymd-His',$data['time'])))}">下载</a></li>
              </ul>
            </span>
            </td>
            <td width="150" align="center">{$data.time|date='Ymd-His',###}</td>
            <td width="150" align="center">{$key}</td>
            <td width="150" align="center">{$data.size|format_bytes}</td>
            <td width="100" align="center">{$data.part}</td>
            <td width="100" align="center">{$data.compress}</td>
            <td width="100" align="center" class="info">-</td>
        </tr>
        {/volist}
      </tbody>
      </table>
    </div>
  </div>
</div>
</div>
<script type="text/javascript">
$('.confirm-on-click').live('click', function() {
  var self = this, code = ".";
  if(confirm('确认导入这项吗？')){
      } else {
      return false;
  }
  $.get(self.href, success, "json");
  window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
  return false;

  function success(data){
      if(data.code){
          if(data.data.gz){
              data.msg += code;
              if(code.length === 5){
                  code = ".";
              } else {
                  code += ".";
              }
          }
          $(self).parents('tr').find('td.info').text(data.msg);
          $(self).parent().prev().text(data.info);
          if(data.data.part){
              $.get(self.href,
                  {"part" : data.data.part, "start" : data.data.start},
                  success,
                  "json"
              );
          }  else {
              window.onbeforeunload = function(){ return null; }
          }
      } else {
          $(self).parents('tr').find('.info').text(data.msg);
      }
  }
});
</script>
{/block}